<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body layadmin-themealias="default">

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15="">

                    <div class="layui-form" wid100="" lay-filter="">
                        <input type="hidden" name="id" value="{$info.id}">

                        <div class="layui-form-item">
                            <label class="layui-form-label">公告内容</label>
                            <div class="layui-input-block">
                                <textarea type="text" maxlength="200" lay-min="10" placeholder="请输入系统提示，10-200个字符数限制" name="content" class="layui-textarea" lay-verify="required|content">{$info.content}</textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">受众范围</label>
                            <div class="layui-input-inline">
                                <select name="type" {$info.type==1?'disabled':''}>
                                    <option value="0" {$info.type==0?'selected':''}>所有房间</option>
                                    {if $info.type==1}
                                    <option value="1" {$info.type==1?'selected':''}>单个直播间</option>
                                    {/if}
                                    <option value="2" {$info.type==2?'selected':''}>娱乐</option>
                                    <option value="3" {$info.type==3?'selected':''}>体育</option>
                                </select>
                            </div>
                        </div>
                        {if $info.type==1}
                        <div class="layui-inline">
                            <label class="layui-form-label">主播ID(房间ID)：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="anchorid" value="{$info.anchorid}" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        {/if}
                        <div class="layui-form-item">
                            <div class="layui-input-block text-center">
                                <button class="layui-btn" lay-submit="" lay-filter="livenotice-edit">确认保存</button>
                                <button class="layui-btn layui-btn-primary" id="close">取消</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script src="/assets/cos-js-sdk-v5/cos-js-sdk-v5.min.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'admin', 'live'], function () {
        var $ = layui.$
            , form = layui.form
            , admin = layui.admin;
        var index = parent.layer.getFrameIndex(window.name);

        $('#close').on("click", function () {
            parent.layer.close(index);
        });

        form.verify({
            content: function (value, item) {
                var min = item.getAttribute('lay-min')
                if (value.length < min) {
                    return "内容长度不能小于" + min + "个字符"
                }
            },
        })

        form.on('submit(livenotice-edit)', function (obj) {
            //提交
            admin.req({
                url: '/admin/live/notice_edit_post'
                , data: obj.field
                , success: function (res) {
                    if (res.code == 0) {
                        parent.layer.close(index);
                        parent.layer.msg(res.msg, {icon: 1});
                        parent.layui.table.reload('LAY-notice-manage');
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
